﻿@using eCollabro.Client.Models.Content;
@using eCollabro.Client.Models.Core;
@using eCollabro.Web.Base;
@using eCollabro.Common;
@model AnnouncementModel
@if (!Request.IsAjaxRequest())
{
    @Scripts.Render("~/bundles/announcement")
}
@{
    List<PermissionEnum> userPermissions = (List<PermissionEnum>)ViewBag.UserPermissions;
    bool canEdit = userPermissions.Contains(PermissionEnum.EditContent);
    bool canDelete = userPermissions.Contains(PermissionEnum.DeleteContent);
    bool canAdd = userPermissions.Contains(PermissionEnum.AddContent);

    List<PageButton> pageButtons = new List<PageButton>();
    pageButtons.Add(new PageButton { Id = "btnAnnouncements", ButtonText = "Announcements", CssClass = "btn btn-success", Icon = "th-list", Method = "openAnnouncements()" });
    if ((canEdit && !Model.AnnouncementId.Equals(0)) || (canAdd && Model.AnnouncementId.Equals(0)))
    {
        pageButtons.Add(new PageButton { Id = "btnSave", ButtonText = "Save",  CssClass = "btn btn-primary", Icon = "floppy-disk", Method = "saveAnnouncement()" });
    }
}
<script type="text/javascript">
    $(document).ready(function () {
        $announcementContentEditor = $("#AnnouncementDescription").cleditor()[0];
        $announcementContentEditor.focus();
    });
</script>
<div id="divAnnouncement" ng-controller="manageAnnouncementController" ng-init="loadAnnouncement(@Model.AnnouncementId)">
    @Html.Partial("_PageHeader", new PageHeaderModel { ViewId = "Announcement", PageTitle = "Announcement - Add/Edit", ValidateForm = true, PageButtons = pageButtons })
    @using (Html.BeginForm("Announcement", "Announcement", FormMethod.Post, new { role = "form", id = "frmAnnouncement", @class = "form-horizontal" }))
    {

        @Html.AntiForgeryToken()
        <div class="form-group">
            @Html.LabelFor(m => m.AnnouncementTitle, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextBoxFor(m => m.AnnouncementTitle, new { ng_model = "announcement.AnnouncementTitle", @class = "form-control", maxlength = "50" })
                @Html.ValidationMessageFor(m => m.AnnouncementTitle)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.AnnouncementDescription, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextAreaFor(m => m.AnnouncementDescription, new { ng_model = "announcement.AnnouncementDescription", @class = "form-control", maxlength = "1000" })
                @Html.ValidationMessageFor(m => m.AnnouncementDescription)
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.IsActive, new { ng_model = "announcement.IsActive" })
                    @Html.LabelFor(m => m.IsActive)
                </div>
            </div>
        </div>
        <div class="col-md-1"></div>
        <div class="col-md-11">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">Content Setting</div>
                <div class="panel-body">
                    <div class="form-group" style="padding-left:5px">
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsAnomynousAccess, new { ng_model = "announcement.IsAnomynousAccess" }) @Html.LabelFor(m => m.IsAnomynousAccess)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsCommentsAllowed, new { ng_model = "announcement.IsCommentsAllowed" }) @Html.LabelFor(m => m.IsCommentsAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsLikeAllowed, new { ng_model = "announcement.IsLikeAllowed" }) @Html.LabelFor(m => m.IsLikeAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsRatingAllowed, new { ng_model = "announcement.IsRatingAllowed" }) @Html.LabelFor(m => m.IsRatingAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsVotingAllowed, new { ng_model = "document.IsVotingAllowed" }) @Html.LabelFor(m => m.IsVotingAllowed)
                        </label>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12">
            @Html.Partial("_PageFooter", new PageFooterModel
                {
                    PageButtons = pageButtons
                })
        </div>

    }
</div>
